package com.faithbj.common.model;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;

/**
 * @author jrn E-mail: rinanjin@gmail.com
 * @version 0.1 
 * 创建时间：2012-6-3 下午07:01:09
 * 类说明
 */
@Entity
@Table(name = "role")
public class Roles extends BaseEntity
{
	private static final long serialVersionUID = 1L;
	
	// 管理员角色-能登陆后台管理系统
	public static final String ROLE_MANAGER = "ROLE_MANAGER";
	
	// 用户角色-能登陆核对系统
	public static final String ROLE_USER = "ROLE_USER";

	private String name;
	
	// 操作人
	private String operator;
	
	// 角色字符串
	private String value;
	
	// 是否为系统内置角色
	private Boolean isSystem;
	
	// 描述
	private String description;
	
	// 该角色所对应的用户列表
	private Set<User> users;

	@Column(name = "name")
	public String getName()
	{
		return name;
	}

	@Column(name = "operator", nullable = false)
	public String getOperator()
	{
		return operator;
	}
	
	@Column(name = "value", nullable = false, unique = true)
	public String getValue()
	{
		return value;
	}
	
	@Column(name = "is_system", nullable = false)
	public Boolean getIsSystem()
	{
		return isSystem;
	}

	@Column(name = "description", nullable = false, unique = true)
	public String getDescription()
	{
		return description;
	}

	@ManyToMany(mappedBy = "roles", fetch = FetchType.LAZY)
	@ForeignKey(name="fk_role_user_set")
	public Set<User> getUsers()
	{
		return users;
	}

	public void setIsSystem(Boolean isSystem) 
	{
		this.isSystem = isSystem;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public void setValue(String value)
	{
		this.value = value;
	}


	public void setOperator(String operator) 
	{
		this.operator = operator;
	}

	public void setUsers(Set<User> users)
	{
		this.users = users;
	}

	public void setName(String name)
	{
		this.name = name;
	}
}
